package com.group.three.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group.three.mapper.VideosMapper;
import com.group.three.pojo.Videos;
import com.group.three.pojo.dto.AddNewVideoDto;
import com.group.three.service.VideosService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideosServiceImpl implements VideosService {
    @Autowired
    private VideosMapper videosMapper;

    @Override
    public List<Videos> selectVideosAll() {
        PageHelper.startPage(1,5);
        return videosMapper.selectVideosAll();
    }

    @Override
    public int deleteVideoId(Long videoId) {
        return videosMapper.deleteVideoId(videoId);
    }

    @Override
    public List<Videos> searchByInput(String input) {
        return videosMapper.searchByInput(input);
    }

    @Override
    public boolean addNewVideo(AddNewVideoDto addNewVideoDto) {
        int i = videosMapper.addNewVideo(addNewVideoDto);
        if (i!=0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<Videos> selectAll(int page, int size) {
        PageHelper.startPage(page,size);
        return videosMapper.selectAll();
    }


}
